package com.wmh.baseservice.operationaid.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wmh.baseservice.common.mybatisplus.structure.LambdaQueryWrapperX;
import com.wmh.baseservice.operationaid.entity.ProductTrafficSource;

import java.util.List;
import java.util.stream.Collectors;


/**
 * @author 谢骏
 * @description 针对表【operation_aid_product_trafficsource(运营助手-商品数据-流量来源)】的数据库操作Mapper
 * @createDate 2023-07-21 11:08:42
 * @Entity generator.domain.ProductTrafficSource
 */
public interface ProductTrafficSourceMapper extends BaseMapper<ProductTrafficSource> {

    /**
     * 获取店铺名称
     * @return 店铺名称列表
     */
    default List<String> selectStoreNameList() {
        return selectList(new LambdaQueryWrapperX<ProductTrafficSource>()
                .groupBy(ProductTrafficSource::getStoreName)
                .orderByDesc(ProductTrafficSource::getCreateTime)
                .select(ProductTrafficSource::getStoreName))
                .stream().map(ProductTrafficSource::getStoreName)
                .collect(Collectors.toList());
    }

    /**
     * 获取流量来源
     * @return 来源列表
     */
    default List<String> selectTrafficsSourceList(){
        return selectList(new LambdaQueryWrapperX<ProductTrafficSource>()
                .groupBy(ProductTrafficSource::getTrafficsSource)
                .orderByDesc(ProductTrafficSource::getCreateTime)
                .select(ProductTrafficSource::getTrafficsSource))
                .stream().map(ProductTrafficSource::getTrafficsSource).collect(Collectors.toList());
    }

    /**
     * 获取数据周期
     * @return 数据周期列表
     */
    default List<String> selectDataCycleList(){
        return selectList(new LambdaQueryWrapperX<ProductTrafficSource>()
                .groupBy(ProductTrafficSource::getDataCycle)
                .orderByDesc(ProductTrafficSource::getCreateTime)
                .select(ProductTrafficSource::getDataCycle)).stream().map(ProductTrafficSource::getDataCycle).collect(Collectors.toList());
    }

}




